Abstract (PEP 557)
Data Classes can be thought of as “mutable namedtuples with defaults”.
「Data Classes use normal class definition syntax」が売り(継承などもできる)
A class decorator is provided which inspects a class definition for variables with type annotations
デコレータがinspectするクラス定義の変数を「このドキュメントではフィールド(field)と呼ぶ」
Using these fields, the decorator adds generated method definitions to the class to support instance initialization, a repr, comparison methods
InventoryItemに特殊メソッドが追加される例
Such a class is called a Data Class, but there’s really nothing special about the class: the decorator adds generated methods to the class and returns the same class it was given.
「デコレータはクラスに生成したメソッド群を追加し、与えられたのと同じ(IMO:同名の)クラスを返す」
Data Classes save you from writing and maintaining these methods.
「一部の特殊メソッドを書いたり保守したりするのを節約する」